package cn.iocoder.yudao.module.product.enums.spu;

import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 发货方式
 *
 * @author lizhongwen
 */
@Getter
@AllArgsConstructor
public enum DeliveryMethodEnum implements IntArrayValuable {

    AUTOMATIC(0, "自动"),
    MANUAL(1, "手动");

    /**
     * 值
     */
    private final int value;
    /**
     * 描述
     */
    private final String desc;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryMethodEnum::getValue).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static DeliveryMethodEnum fromValue(int value) {
        for (DeliveryMethodEnum item : values()) {
            if (item.value == value) {
                return item;
            }
        }
        throw new IllegalArgumentException("枚举类型 DeliveryMethodEnum 不支持整型值：" + value);
    }

    public static Boolean isAutomatic(Integer value) {
        return ObjectUtil.equals(AUTOMATIC.getValue(), value);
    }

}
